import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'
import directive from '@/views/permission/directive'
import role from '@/views/permission/role'
/* Router Modules */
import componentsRouter from './modules/components'
import chartsRouter from './modules/charts'
import tableRouter from './modules/table'
import { comment } from 'jszip/lib/defaults'
// import nestedRouter from './modules/nested'


export const constantRoutes = [{
		path: '/redirect',
		component: Layout,
		hidden: true,
		children: [{
			path: '/redirect/:path(.*)',
			component: () => import('@/views/redirect/index')
		}]
	},

	{
		path: '/auth-redirect',
		component: () => import('@/views/login/auth-redirect'),
		hidden: true
	},
	{
		path: '/404',
		component: () => import('@/views/error-page/404'),
		hidden: true
	},
	{
		path: '/401',
		component: () => import('@/views/error-page/401'),
		hidden: true
	},
	{
		path: '/',
		component: Layout,
		redirect: '/dashboard',
		children: [{
			path: 'dashboard',
			component: () => import('@/views/dashboard/index'),
			name: 'Dashboard',
			meta: {
				title: '首页',
				icon: 'dashboard',
				affix: true
			}
		}],

	},
    
]

/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
export const asyncRoutes = [
	{
		path: '/login',
		component: () => import('@/views/login/index'),
		hidden: true
	},
	
	{
		path: '/permission',
		component: Layout,
		redirect: '/permission/page',
		alwaysShow: true, // will always show the root menu
		name: 'Permission',
		meta: {
			title: '授权管理',
			icon: 'lock',
			roles: ['admin', 'editor'] // you can set roles in root nav
		},
		children: [
			{
				path: 'export-selected-excel',
				component: () => import('@/views/excel/select-excel'),
				name: '授权审核',
				meta: {
					title: '授权审核'
				}
			},
			{
				path: 'index',
				component: () => import('@/views/tab/index'),
				name: 'indexjxs',
				meta: {
					title: '授权申请',
					icon: 'tab'
				}
			},
			{
				path: 'directive',
				 component:() => import('@/views/permission/directive'),
				name: 'DirectivePermission',
				meta: {
					title: '授权查询'
					// if do not set roles, means: this page does not require permission
				}
			},
			{
				path: 'role',
				component: () => import('@/views/permission/role'),
				name: 'RolePermission',
				meta: {
					title: '库存查询',
					roles: ['admin']
				}
			}
		]
	},

	{
		path: '/icon',
		component: Layout,
		redirect: '/profile/index',
		alwaysShow: true, // will always show the root menu
		name: 'icon',
		meta: {
			title: '订单管理',
			icon: 'lock',
			roles: ['admin', 'editor'] // you can set roles in root nav
		},
		children: [
			{
				path: 'zhangqi',
				component: () => import('@/views/yonghu/zhangqi'),
				name: '账期付款审核',
				meta: {
					title: '账期付款审核'
				}
			},
			{
				path: 'clipboardindex',
				component: () => import('@/views/clipboard/index'),
				name: '历史订单导入',
				meta: {
					title: '历史订单导入'
				}
			},
			{
				path: 'index',
				component: () => import('@/views/icons/index'),
				name: 'Icons',
				meta: {
					title: '订货申请',
					icon: 'icon',
					
				}
			},
			{
				path: 'uploadavatar',
				component: () => import('@/views/components-demo/avatar-upload'),
				name: '订货单',
				meta: {
					title: '订货单'
				}
			},{
				path: 'backtop',
				component: () => import('@/views/components-demo/back-to-top'),
				name: '换货单',
				meta: {
					title: '换货单'
				}
			},
			
			
		
			{
				path: 'documentation',
				component: () => import('@/views/documentation/index'),
				name: 'documentation',
				meta: {
					title: '换货申请',
					icon: 'icon',
					noCache: true
				}
			},
			{
				path: 'dinhuo',
				component: () => import('@/views/yonghu/dinhuo'),
				name: '订单申请审核',
				meta: {
					title: '订单申请审核'
				}
			}
			
		]
	},
	{
		path: '/compyangping',
		component: Layout,
		redirect: 'compyangping',
		name: 'compyangping',
		meta: {
		  title: '样品管理',
		  icon: 'component'
		},
		children: [
			{
				path: 'index',
				component: () => import('@/views/profile/index'),
				name: '样品申请',
				meta: {
					title: '样品申请',
					icon: 'user',
					noCache: true
				}
			},
			{
				path: 'download',
				component: () => import('@/views/pdf/download'),
				name: '样品申请审核',
				meta: {
					title: '样品申请审核'
				}
			},
			{
				path: 'permission',
				component: () => import('@/views/permission/page'),
				name: 'permission',
				meta: {
					title: '样品申领',
					icon: 'icon',
					
				}
			},
		]
	},
    {
		path: '/components',
		component: Layout,
		redirect: 'noRedirect',
		name: 'ComponentDemo',
		meta: {
		  title: '积分管理',
		  icon: 'component'
		},
		children: [
			{
				path: 'indexsq',
				component: () => import('@/views/error-log/index'),
				name: '积分规则申请',
				meta: {
					title: '积分规则申请',
					icon: 'tab'
				}
			},

		  {
			path: 'tinymce',
			component: () => import('@/views/components-demo/tinymce'),
			name: 'TinymceDemo',
			meta: { title: '积分查询' }
		  },
		  {
			path: 'split-pane',
			component: () => import('@/views/components-demo/split-pane'),
			name: 'SplitpaneDemo',
			meta: { title: '季度申领' }
		  },
		
		  {
			path: 'json-editor',
			component: () => import('@/views/components-demo/json-editor'),
			name: 'JsonEditorDemo',
			meta: { title: '年度申领' }
		  },
		  {
			path: 'jifenguanli',
			component: () => import('@/views/components-demo/jifenguanli'),
			name: 'jifen',
			meta: { title: '积分使用管理' }
		  },
		  {
			path: 'upload-excel',
			component: () => import('@/views/excel/upload-excel'),
			name: '积分发放管理',
			meta: {
				title: '积分发放管理'
			}
		},
		{
			path: 'downloadzip',
			component: () => import('@/views/zip/index'),
			name: '年度积分发放管理',
			meta: {
				title: '年度积分发放管理'
			}
		},
		{
			path: 'index',
			component: () => import('@/views/pdf/index'),
			name: '积分规则申请审核',
			meta: {
				title: '积分规则申请审核'
			}
		},
		]
	},
	// /** when your routing map is too long, you can split it into small modules **/
	// componentsRouter,
	{
		path: '/charts',
		component: Layout,
		redirect: 'noRedirect',
		name: 'Charts',
		meta: {
		  title: '合同管理',
		  icon: 'chart'
		},
		children: [
			{
				path: 'export-merge-header',
				component: () => import('@/views/excel/merge-header'),
				name: '合同管理',
				meta: {
					title: '合同管理'
				}
			},
		  {
			path: 'keyboard',
			component: () => import('@/views/charts/keyboard'),
			name: 'KeyboardChart',
			meta: { title: '合同查询'}
		  }
		  
		]
	  },
	  {
		path: '/table',
		component: Layout,
		redirect: '/table/complex-table',
		name: 'Table',
		meta: {
		  title: '普实资料',
		  icon: 'table'
		},
		children: [
			{
				path: 'chartsindex',
				component: () => import('@/views/charts/index'),
				name: '产品资料',
				meta: {
					title: '产品资料'
				}
			},
			{
				path: 'chartsmix-chart',
				component: () => import('@/views/charts/mix-chart'),
				name: '首营资料',
				meta: {
					title: '首营资料'
				}
			},
		  {
			path: 'dynamic-table',
			component: () => import('@/views/table/dynamic-table/index'),
			name: 'DynamicTable',
			meta: { title: '产品资料查询' }
		  },
		  {
			path: 'drag-table',
			component: () => import('@/views/table/drag-table'),
			name: 'DragTable',
			meta: { title: '首营资料查询' }
		  },
		  {
			path: 'chartsline',
			component: () => import('@/views/charts/line'),
			name: '普实程序',
			meta: {
				title: '普实程序'
			}
		},
		 
		]
	  },
	// nestedRouter,
	// tableRouter,

	{
		path: '/example',
		component: Layout,
		redirect: '/example/list',
		name: 'Example',
		meta: {
			title: '留言板',
			icon: 'el-icon-s-help'
		},
		children: [

			{
				path: 'list',
				component: () => import('@/views/example/list'),
				name: 'ArticleList',
				meta: {
					title: '留言信息',
					icon: 'list'
				}
			}
		]
	},

	{
		path: '/tab',
		component: Layout,
		redirect: '/example/list',
		name: 'Example',
		meta: {
			title: '经销商授权',
			
		},
		children: [

		]
	},
	{
		path: '/errortab',
		component: Layout,
		children: [
		]
	},
	{
		path: '/profile',
		component: Layout,
		children: []
	},
	{
		path: '/create',
		component: Layout,
		redirect: '/example/create',
		name: '综合业务',
		meta: {
			title: '综合业务',
			icon: 'el-icon-s-help'
		},
		children: [{
				path: 'guideindex',
				component: () => import('@/views/guide/index'),
				name: '医院地区',
				meta: {
					title: '医院地区',
					icon: 'edit'
				}
			},
			{
				path: 'excelindex',
				component: () => import('@/views/excel/export-excel'),
				name: '企业管理',
				meta: {
					title: '企业管理',
					icon: 'tab'
				}
			},

		]
	},
	{
		path: '/jingxiaosahng',
		component: Layout,
		redirect: '/example/create',
		name: 'jingxiaosahng',
		meta: {
			title: '经销商授权申请管理',
			icon: 'el-icon-s-help'
		},
		children: [
			
			
			

		]
	},
	{
		path: '/clipboard',
		component: Layout,
		redirect: '/example/create',
		name: '经销商历史订单管理',
		meta: {
			title: '综合业务',
			icon: 'el-icon-s-help'
		},
		children: [

		]
	},
	{
		path: '/clipboard',
		component: Layout,
		redirect: '/example/create',
		name: '普实资料管理',
		meta: {
			title: '普实资料管理',
			icon: 'el-icon-s-help'
		},
		children: [
			


		]
	},
	{
		path: '/components-demo',
		component: Layout,
		redirect: '/example/create',
		name: '植入系统基本信息',
		meta: {
			title: '植入系统基本信息',
			icon: 'el-icon-s-help'
		},
		children: [{
				path: 'split',
				component: () => import('@/views/components-demo/dropzone'),
				name: '植入系统基本信息',
				meta: {
					title: '植入系统基本信息'
				}
			},
			
		]
	},
	{
		path: '/dindanshenhe',
		component: Layout,
		redirect: '/example/create',
		name: '订单审核',
		meta: {
			title: '订单审核',
			icon: 'el-icon-s-help'
		},
		children: [
		]
	},
	{
		path: '/dindanshenhe',
		component: Layout,
		redirect: '/example/create',
		name: '仓库管理',
		meta: {
			title: '出入库管理',
			icon: 'el-icon-s-help'
		},
		children: [{
				path: 'countto',
				component: () => import('@/views/components-demo/count-to'),
				name: '产品入库',
				meta: {
					title: '产品入库'
				}
			},{
				path: 'dndlist',
				component: () => import('@/views/components-demo/dnd-list'),
				name: '内部出库',
				meta: {
					title: '内部出库'
				}
			},
			{
				path: 'dragdialog',
				component: () => import('@/views/components-demo/drag-dialog'),
				name: '产品出库',
				meta: {
					title: '产品出库'
				}
			},
            {
				path: 'jingxiaoshang',
				component: () => import('@/views/yonghu/jingxiaoshang'),
				name: '经销商库存查询',
				meta: {
					title: '经销商库存查询'
				}
			},
			{
				path: 'dndlisttj',
				component: () => import('@/views/components-demo/drag-select'),
				name: '统计',
				meta: {
					title: '统计'
				}
			},
            {
				path: 'counttos',
				component: () => import('@/views/components-demo/drag-kanban'),
				name: 'counttos',
				meta: {
					title: '查询'
				}
			},
			
		]
	},
	{
		path: '/kucguanli',
		component: Layout,
		redirect: '/example/create',
		name: '库存管理',
		meta: {
			title: '库存管理',
			icon: 'el-icon-s-help'
		},
		children: [
			
			
		]
	},
	{
		path: '/kucguanli',
		component: Layout,
		redirect: '/example/create',
		name: '物流管理',
		meta: {
			title: '物流管理',
			icon: 'el-icon-s-help'
		},
		children: [{
				path: 'mixin',
				component: () => import('@/views/components-demo/mixin'),
				name: '物流查询',
				meta: {
					title: '物流查询'
				}
			}
			
		]
	},
	// {
	// 	path: '/yonghu',
	// 	component: Layout,
	// 	redirect: '/example/create',
	// 	name: '用户管理',
	// 	meta: {
	// 		title: '用户管理',
	// 		icon: 'el-icon-s-help'
	// 	},
	// 	children: [
	// 		// {
	// 		// 	path: 'yonghu',
	// 		// 	component: () => import('@/views/yonghu/yonghu'),
	// 		// 	name: '部门职位',
	// 		// 	meta: {
	// 		// 		title: '部门职位'
	// 		// 	}
	// 		// },
	// 		{
	// 			path: 'yonghuadd',
	// 			component: () => import('@/views/yonghu/yonghuadd'),
	// 			name: '添加人员',
	// 			meta: {
	// 				title: '添加人员'
	// 			}
	// 		}
			
	// 		// ,{
	// 		// 	path: 'yonghudel',
	// 		// 	component: () => import('@/views/yonghu/yonghudel'),
	// 		// 	name: '删除人员',
	// 		// 	meta: {
	// 		// 		title: '删除人员'
	// 		// 	}
	// 		// },
	// 	]
	// },
	{
		path: '/dinhuoshenhe',
		component: Layout,
		redirect: '/example/create',
		name: '订货审核',
		meta: {
			title: '订货审核',
			icon: 'el-icon-s-help'
		},
		children: [
			
		]
	},
	{
		path: '/fukuanshenhe',
		component: Layout,
		redirect: '/example/create',
		name: '账期审核',
		meta: {
			title: '账期审核',
			icon: 'el-icon-s-help'
		},
		children: [
			
			
		]
	},
	{
		path: '/jingxiaoshangkucun',
		component: Layout,
		redirect: '/example/create',
		name: '经销商库存',
		meta: {
			title: '经销商库存',
			icon: 'el-icon-s-help'
		},
		children: [
			
			
		]
	},
	{
    	path: '/xitongguanli',
    	component: Layout,
    	redirect: '/dashboard',
		alwaysShow: true, // will always show the root menu
		name: 'Permission',
		meta: {
			title: '系统管理',
			icon: 'lock',
			roles: ['admin', 'editor'] // you can set roles in root nav
		},
    	children: [{
    		path: 'juese',
    		component: () => import('@/views/dashboard/juese'),
    		name: 'juese',
    		meta: {
    			title: '角色管理',
    			icon: 'dashboard',
    			affix: true
    		}
    	},{
    		path: 'caidan',
    		component: () => import('@/views/dashboard/caidan'),
    		name: 'caidan',
    		meta: {
    			title: '菜单管理',
    			icon: 'dashboard',
    			affix: true
    		}
    	}

	]
    },
	{
    	path: '/juese',
    	component: Layout,
    	redirect: '/dashboard',
		alwaysShow: true, // will always show the root menu
		name: 'Permission',
		meta: {
			title: '权限管理',
			icon: 'lock',
			roles: ['admin', 'editor'] // you can set roles in root nav
		},
    	children: [{
    		path: 'bumen',
    		component: () => import('@/views/dashboard/bumen'),
    		name: 'bumen',
    		meta: {
    			title: '部门管理',
    			icon: 'dashboard',
    			affix: true
    		}
    	},{
    		path: 'zhiwei',
    		component: () => import('@/views/dashboard/zhiwei'),
    		name: 'zhiwei',
    		meta: {
    			title: '职位管理',
    			icon: 'dashboard',
    			affix: true
    		}
    	},{
    		path: 'quyu',
    		component: () => import('@/views/dashboard/quyu'),
    		name: 'quyu',
    		meta: {
    			title: '区域管理',
    			icon: 'dashboard',
    			affix: true
    		}
    	},{
			path: 'yonghuadd',
			component: () => import('@/views/yonghu/yonghuadd'),
			name: 'yonghuadd',
			meta: {
				title: '用户管理',
    			icon: 'dashboard',
    			affix: true
			}
		},
		{
			path: 'theme',
			component: () => import('@/views/theme/index'),
			name: '经销商用户管理',
			meta: {
				title: '经销商用户管理'
			}
		},

	]
    },
	{
		path: '*',
		redirect: '/404',
		hidden: true
	}
]

const createRouter = () => new Router({
	// mode: 'history', // require service support
	scrollBehavior: () => ({
		y: 0
	}),
	routes: [ ...constantRoutes, ...asyncRoutes ]
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
	const newRouter = createRouter()
	router.matcher = newRouter.matcher // reset router
}

export default router